﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace _3Dshower
{
    class MyModel
    {
        public plane[] planes;
        public Point[] points;//其中包括中心点
        public Color getPointColor(double x, double y)
        {
            Color ShowColor = Color.Black;
            double? deepest = null;
            double? tempDeep= null;
            foreach (var pla in planes)
            {
                tempDeep = pla.pointDeep(x, y);
                if (tempDeep.HasValue)
                {
                    if (!deepest.HasValue)
                    {
                        deepest = tempDeep;
                        ShowColor = pla.color;
                    }
                    else
                    {
                        if (deepest < tempDeep)
                        {
                            deepest = tempDeep;
                            ShowColor = pla.color;
                        }
                    }
                }
            }
            return ShowColor;
        }
        public void move(Point moveP)
        {
            for (int i = 0; i < points.Length; ++i)
                points[i].changeCoor(moveP);
        }
        public void moveHorAngle(double Angle)
        {
            for (int i = 0; i < points.Length; ++i)
                points[i].changeHorAngle(Angle);
            for (int i = 0; i < planes.Length; ++i)
                planes[i].reCal();
        }
        public void moveVerAngle(double Angle)
        {
            for (int i = 0; i < points.Length; ++i)
                points[i].changeVerAngle(Angle);
            for (int i = 0; i < planes.Length; ++i)
                planes[i].reCal();
        }
    }
}
